/**
 * 
 */
package org.mspring.mlog.web.security.login;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.mspring.platform.utils.Assert;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

/**
 * @author Gao Youbo
 * @since 2013-6-8
 * @description
 * @TODO
 */
public class LoginPageEntryPoint implements AuthenticationEntryPoint, InitializingBean {

    private LoginPageStrategy loginPageStrategy;

    public void setLoginPageStrategy(LoginPageStrategy loginPageStrategy) {
        this.loginPageStrategy = loginPageStrategy;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        // TODO Auto-generated method stub
        Assert.notNull(loginPageStrategy, "loginPageStrategy must be specified");
    }

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2) throws IOException, ServletException {
        // TODO Auto-generated method stub
        loginPageStrategy.process(request, response);
    }
    
    

}
